﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CCWin;
using CCWin.Win32;
using CCWin.Win32.Const;
using CCWin.SkinControl;
using GroupChat2013.Common;
using GroupChat2013.Entity;
using GroupChat2013.Logic;
using GroupChat2013.Service;

namespace GroupChat2013.Main
{
    public partial class FrmResetPassword : CCSkinMain
    {
        private UserInfo currentUser;

        public FrmResetPassword(UserInfo currentUser)
        {
            InitializeComponent();

            this.currentUser = currentUser;
        }

        //窗口加载时
        private void FrmInformation_Load(object sender, EventArgs e)
        {

        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void skinButton1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(stbpassword1.SkinTxt.Text) ||
                string.IsNullOrEmpty(stbpassword2.SkinTxt.Text))
            {
                MessageBoxEx.Show("密码和确认密码项不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
                return;
            }

            if (!stbpassword1.SkinTxt.Text.Equals(stbpassword2.SkinTxt.Text))
            {
                MessageBoxEx.Show("密码和确认密码必须相同", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
                return;
            }

            if (ServiceUrlProxy.GetInstance().UpdateUserInfo(currentUser.UserId, stbpassword1.SkinTxt.Text, currentUser.CID))
            {
                MessageBoxEx.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
                this.Close();
                return;
            }
            else
            {
                MessageBoxEx.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
                return;
            }
        }
    }
}
